<#include "header.htm"/>
<#import "../macros/pagination.ftl" as pagination/>
<#import "../macros/presentation.ftl" as presentation/>

<#assign canEditSomeMessage = false/>

<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/jquery.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/jquery.jeditable.pack.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/post_show.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/post.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/pagination.js?${startupTime}"></script>

<#if logged>
	<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/watch.js?${startupTime}"></script>
</#if>

<script type="text/javascript">
<!--
<#include "js/karma.js">
<#include "js/utils.js"/>

<#if canRemove || isModerator || isAdmin>
	function confirmDelete(postId)
	{
		if (confirm("${I18n.getMessage("Moderation.ConfirmPostDelete")}")) {
			var reason = prompt("${I18n.getMessage("ModerationLog.changeReason")}");

			if (reason == null || reason == "") {
				alert("${I18n.getMessage("ModerationLog.reasonIsEmpty")}");
				return false;
			}
			else {
				var link = document.getElementById("delete" + postId);
				link.href += "&log_description=" + encodeURIComponent(reason) + "&log_type=1";
			}

			return true;
		}
		
		return false;
	}
</#if>

-->
</script>

<#if moderator>
	<script type="text/JavaScript" src="${JForumContext.encodeURL("/js/list/moderation")}"></script>
</#if>




<div id="page-body">

<h2>
   <#if rssEnabled>
      <a href="${contextPath}/rss/topicPosts/${topic.id}${extension}"><img src="${contextPath}/templates/${templateName}/img/feed.gif" border="0" alt="XML" /></a>
   </#if>
   <a href="${JForumContext.encodeURL("/posts/list/${topic.id}")}">${topic.title?html}</a></h2>

<div class="topic-actions">

	<div class="buttons">
		<#if topic.status == STATUS_LOCKED>
			<div class="locked-icon"><a rel="nofollow"><span></span>${I18n.getMessage("PostShow.locked")}</a></div>
		<#else>
			<#if !readonly>
                 <div class="reply-icon"><a href="${JForumContext.encodeURL("/posts/reply/${start}/${topic.id}")}" rel="nofollow"><span></span>${I18n.getMessage("PostShow.postReply")}</a></div>
			</#if>
		</#if>
	</div>


	<div class="pagination">
         <#assign paginationData><@pagination.doPagination "list", topic.id/></#assign>
         ${paginationData}
	</div>


</div>



				<#if poll?exists>
							<#if (poll.open && canVoteOnPoll && !request.getParameter("viewResults")?exists)>
								<form action="${JForumContext.encodeURL("/jforum")}" method="post">
									<input type="hidden" name="action" value="vote" />
									<input type="hidden" name="module" value="${moduleName}" />
									<input type="hidden" name="poll_id" value="${poll.id}" />
									<input type="hidden" name="topic_id" value="${topic.id}" />
									
									
									
	<div class="panel">
		<div class="inner"><span class="corners-top"><span></span></span>
		<div class="content">
		
			<h2>${poll.label?html}</h2>
            <p class="author"></p>
			<fieldset class="polls">
						<#list poll.options as option>
							<dl class="">
								<dt><label>${option.text?html}</label></dt>
								<dd style="width: auto;"><input type="radio" name="poll_option" value="${option.id}"></dd>
							</dl>
						</#list>
		

                <dl style="border-top: none;">
					<dt>&nbsp;</dt>
					<dd class="resultbar"><input type="submit" value="${I18n.getMessage("PostShow.pollVote")}" class="button1"></input></dd>
				</dl>


 				<dl style="border-top: none;">
					<dt>&nbsp;</dt>
					<dd class="resultbar"><a href="${JForumContext.encodeURL("/jforum${extension}?module=posts&amp;action=list&amp;topic_id=${topic.id}&amp;viewResults=true", "")}">${I18n.getMessage("PostShow.showPollResults")}</a></dd>
				</dl>
			</fieldset>
		</div>

		<span class="corners-bottom"><span></span></span></div>
	</div>
	</form>
							<#else>
								<@presentation.renderPoll poll/>
							</#if>
				</#if>

<div class="clear"></div>


				<!-- POST LISTING --> 
				<#assign rowColor = ""/>
				<#list posts as post>
					<#if post_index % 2 == 0>
						<#assign rowColor = "bg2">
					<#else>
						<#assign rowColor = "bg1">
					</#if>
	
					<#assign user = users.get(post.userId)/>
					<#assign canEditCurrentMessage = (post.canEdit && topic.status != STATUS_LOCKED) || moderatorCanEdit/>
					
					<div class="post ${rowColor} <#if post.userId != 1><#if user.isOnline()>online</#if></#if>">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="postbody">
			
				<ul class="profile-icons">
				
				   <#if karmaEnabled>
				   		<li><script type="text/javascript">writeStars(${post.karma.karmaPoints}, ${post.id});</script></li>
				   </#if>
				   <#if (canEditCurrentMessage)>
				   		<li class="edit-icon"><a href="${JForumContext.encodeURL("/jforum${extension}?module=${moduleName}&amp;action=edit&amp;post_id=${post.id}&amp;start=${start}","")}" rel="nofollow"><span>${I18n.getMessage("PostShow.editPost")}</span></a></li>
				   </#if>
				   <#if canRemove>
				   		<li class="delete-icon"><a href="${JForumContext.encodeURL("/jforum${extension}?module=${moduleName}&amp;action=delete&amp;post_id=${post.id}&amp;start=${start}","")}" id="delete${post.id}" onclick="return confirmDelete(${post.id});"><span>${I18n.getMessage("PostShow.deletePost")}</span></a></li>
				   		
				   </#if>
				   <#if topic.status != STATUS_LOCKED && !readonly>
				   		<li class="quote-icon"><a href="${JForumContext.encodeURL("/posts/quote/${start}/${post.id}")}" rel="nofollow" ><span>${I18n.getMessage("PostShow.quote")}</span></a></li>
				   </#if>
				  
				</ul>
			

			<h3 class="first"><a name="${post.id}">${post.subject?default("")?html}</a></h3>
		    <#assign startStr = ""/>
		    <#if (start > 0)><#assign startStr = "${start}/"/></#if>
			<p class="author"><a href="${JForumContext.encodeURL("/posts/list/${startStr}${post.topicId}")}#${post.id}"><img src="${contextPath}/templates/${templateName}/img/icon_post_target.gif" width="11" height="9" alt="Post" title="Post"></a>${I18n.getMessage("by")} <strong><a href="${JForumContext.encodeURL("/user/profile/${user.id}")}" style="color: #AA0000;" class="username-coloured">${user.username?html}</a></strong> &raquo; ${post.formatedTime} </p>

			

			<div class="content">
				<#if canEditCurrentMessage>
					<#assign canEditSomeMessage = true/>
					<div class="edit_area" id="${post.id}">${post.text}</div>
				<#else>
					${post.text}
				</#if>
			</div>
			
									<!-- Attachments -->
							<#if post.hasAttachments() && (canDownloadAttachments || attachmentsEnabled)>
								<#assign attachments = am.getAttachments(post.id, post.forumId)/>

								<#include "post_show_attachments_inc.htm"/>
								<div class="clear"></div>
							</#if>

							<#if (post.editCount > 0) && post.editTime?exists>
								<#if post.editCount == 1>
									<#assign editCountMessage = "PostShow.editCountSingle"/>
								<#else>
									<#assign editCountMessage = "PostShow.editCountMany"/>
								</#if>
								
								<p><i><span class="gensmall">${I18n.getMessage(editCountMessage, [post.editCount, post.editTime?datetime?string])}</span></i></p>
							</#if>
	    
		<#if karmaEnabled && post.userId != session.userId && logged>
		<ul class="profile-icons">
		   <li>
		   <#if !karmaVotes.containsKey(post.id)>
			   <script type="text/javascript">karmaPointsCombo(${post.id})</script>
		   <#else>
			   ${I18n.getMessage("Karma.yourRate")}: ${karmaVotes.get(post.id)}
		   </#if>
		   </li>
		</ul>
		
		
		
	    </#if>
			<#assign useSignature = (user.attachSignatureEnabled && user.signature?exists && user.signature?length > 0 && post.isSignatureEnabled())/>
			<#if useSignature>
    			<div class="signature">${user.signature}</div>
			</#if>


		</div>
		

		
			<dl class="postprofile">
			<dt>
				<a href="${JForumContext.encodeURL("/user/profile/${user.id}")}" style="color: #AA0000;" class="username-coloured">${user.username?html}</a>
			</dt>
			
	        <#if (user.avatar?exists && user.avatar?length > 0)>
	        	<#if user.isExternalAvatar() || user.avatar.startsWith("http://")>
	        		<#if avatarAllowExternalUrl>
	        			<dd><img src="${user.avatar?html}" border="0" alt="[Avatar]" /></dd>
	        		</#if>
	        	<#else>
	        		<dd><img src="${contextPath}/images/avatar/${user.avatar}" border="0" alt="[Avatar]" /></dd>
	        	</#if>
	        </#if>

			<#if post.userId != 1>
				<dd>${rank.getRankTitle(user.rankId, user.totalPosts)}</dd>
			</#if>
			
			<#if karmaEnabled && post.userId != 1>
	            <script type="text/javascript">writeStars(${user.karma.karmaPoints}, "${user.id}${post.id}");</script>
	        </#if>
	        


		<dd>&nbsp;</dd>

        <#if post.userId != 1>
        	<dd><strong>${I18n.getMessage("PostShow.userTotalMessages")}:</strong> ${user.totalPosts}</dd>
	        <dd><strong>${I18n.getMessage("PostShow.userRegistrationDate")}</strong>: ${user.registrationDate}</dd>
        </#if>
        <#if (user.from?exists && user.from?length > 0)>
	        <dd><strong>${I18n.getMessage("PostShow.userFrom")}:</strong> ${user.from?html}</dd>
	    </#if>
	    <#if post.userIp?exists && isModerator>
	    	<dd><strong>${I18n.getMessage("PostShow.userIP")}:</strong> ${post.userIp}</dd>
	    </#if>

			<dd>
				<ul class="profile-icons">
                   <li class="pm-icon"><a href="${JForumContext.encodeURL("/pm/sendTo/${user.id}")}"></a></li>
                   
                   					
				
		<#if (user.isViewEmailEnabled() && user.email?exists && user.email?length > 0)>
			<#assign e = user.email.split("@")/>

			<#if e?size == 2>
				<li class="email-icon"><a href="javascript:sendEmail('${e[0]}', '${e[1]}');"></a></li>
			</#if>
		</#if>
		
		<#if (user.webSite?exists && user.webSite?length > 0)>
		    <li class="web-icon"><a href="${user.webSite?html}" ></a></li>
		</#if>
		
		<#if (user.yim?exists && user.yim?length > 0)>
		    <li class="yim-icon"><a href="http://edit.yahoo.com/config/send_webmesg?.target=${user.yim?html}&amp;.src=pg" ></a></li>
		</#if>

		<#if (user.aim?exists && user.aim?length > 0)>
		    <li class="aim-icon"><a href="https://my.screenname.aol.com/_cqr/login/login.psp" ></a></li>
		</#if>
		
		<#if (user.msnm?exists && user.msnm?length > 0)>
		    <li class="msnm-icon"><a href="${JForumContext.encodeURL("/user/profile/${user.id}")}" ></a></li>
		</#if>
		
		<#if (user.icq?exists && user.icq?length > 0)>
		    <li class="icq-icon"><a href="http://wwp.icq.com/scripts/search.dll?to=${user.icq?html}"></a></li>
		</#if>			
				</ul>
			</dd>
		

		</dl>
	

		<div class="back2top"><a href="#top" class="top" title="Top">Top</a></div>

		<span class="corners-bottom"><span></span></span></div>
</div>
	

				</#list>
     
				<!-- END OF POST LISTING -->
     			<#if isModerator || isAdmin>
					<@presentation.moderationImages/>
				</#if>
	<hr>


<div class="topic-actions">
	<div class="buttons">
	
						<#if topic.status == STATUS_LOCKED>
            				<div class="locked-icon"><a rel="nofollow"><span></span>${I18n.getMessage("PostShow.locked")}</a></div>
						<#else>
							<#if !readonly>
		                        <div class="reply-icon"><a href="${JForumContext.encodeURL("/posts/reply/${start}/${topic.id}")}" rel="nofollow"><span></span>${I18n.getMessage("PostShow.postReply")}</a></div>
							</#if>
						</#if>
	
	</div>

	
		<div class="pagination">
			${paginationData}
		</div>
	
</div>

    <p></p>
    
	<@presentation.forumsComboTable/>
	

	




</div>




				
				<#if (logged || anonymousPosts) && topic.status != STATUS_LOCKED && !readonly>
					<script type="text/javascript">
					function newCaptcha()
					{
						document.getElementById("captcha_img").src = "${contextPath}/jforum${extension}?module=captcha&action=generate&timestamp=" + new Date().getTime();
					}
					
					function activateQuickReply()
					{
						$("#captcha_img").attr("src", "${JForumContext.encodeURL("/captcha/generate/${timestamp}")}");
						$("#quickReply").slideToggle('slow', function() {
							window.scrollBy(0, 1000);
						});
					}

					function validatePostForm(f)
					{
						if (f.message.value.replace(/^\s*|\s*$/g, "").length == 0) {
							alert("${I18n.getMessage("PostForm.textEmpty")}");
							f.message.focus();
						
							return false;
						}
					
						$("#icon_saving").css("display", "inline");
						$("#btnSubmit").attr("disabled", "disabled").val("${I18n.getMessage("PostForm.saving")}...");
					
						return true;
					}
					-->
					</script>

					
					<form action="${JForumContext.encodeURL("/jforum")}" method="post" name="post" id="post" onsubmit="return validatePostForm(this);" enctype="multipart/form-data" accept-charset="${encoding}">
						<input type="hidden" name="action" value="insertSave" />
						<input type="hidden" name="module" value="posts" />
						<input type="hidden" name="forum_id" value="${forum.id}" />
						<input type="hidden" name="start" value="${start?default("")}" />
						<input type="hidden" name="topic_id" value="${topic.id}" />
						<input type="hidden" name="disable_html" value="1" />
						<input type="hidden" name="quick" value="1" />
	
						
						<fieldset class="display-options">
	<a href="javascript:activateQuickReply()">${I18n.getMessage("PostForm.quickReply")}</a>
	                    </fieldset>
						
						<div class="post " id="quickReply" style="display:none">
		                   <div class="inner"><span class="corners-top"><span></span></span>

										<#if needCaptcha?default(false)>
									<#include "captche.htm"/>
								</#if>
								<fieldset class="display-options">
			                    <textarea class="post" style="width: 350px" name="message" rows="10" cols="35" onkeyup="enterText(this);" onclick="enterText(this);" onselect="enterText(this);" onblur="leaveText();"></textarea>
                                <br/>
                                <input type="submit" id="btnSubmit" value="${I18n.getMessage("PostForm.submit")}" class="button2" />
								</fieldset>
                    		    <span class="corners-bottom"><span></span></span>
                    		</div>
                    	</div>
						
						

						
		
						
	
						
						
					</form>

				</#if>
				


<a name="quick"></a>

<script type="text/javascript">
$(document).ready(function() {
	limitURLSize();

	<#if moderatorCanEdit || canEditSomeMessage>
		$(".edit_area").editable("${contextPath}/jforum${extension}?module=ajax&action=savePost", {
			submit: '${I18n.getMessage("Update")}',
			cancel: '${I18n.getMessage("cancel")}',
			type: 'textarea',
			tooltip: '${I18n.getMessage("PostShow.doubleClickEdit")}',
			rows: 15,
			width: '100%',
			event: 'dblclick',
			indicator: "<img src='${contextPath}/templates/${templateName}/images/indicator.gif'>",
			postload: '${contextPath}/jforum${extension}?module=ajax&action=loadPostContents',
			cssclass: 'inlineedit',
			loadtext: '${I18n.getMessage("PostShow.loading")}...',
			beforesubmit: function(submitdata) { 
				<#if moderationLoggingEnabled>
					var message = prompt("${I18n.getMessage("ModerationLog.changeReason")}");

					if (message == null || message == "") {
						alert("${I18n.getMessage("ModerationLog.reasonIsEmpty")}");
						return false;
					}
					else {
						submitdata["log_description"] = message;
						submitdata["log_type"] = 2;
					}
				</#if>

				return true;
			}
		}, function(s) {
			<#if hasCodeBlock>
				dp.sh.HighlightAll('code');
			<#else>
				if (s.indexOf("name=\"code\"") > -1) {
					document.location.reload(true);
				}
			</#if>
		});
	</#if>
});
</script>

<#include "bottom.htm"/>